<template>
  <div id="DeliverList">
    <el-table :data="resumeList" border highlight-current-row fit>
      <el-table-column type="index" :label="$t('index')" width="70" align="center">
      </el-table-column>
      <el-table-column prop="resume_name" label="简历名称" align="center">
      </el-table-column>
      <el-table-column prop="company_name" label="单位名称" align="center" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="job_title" label="职位名称" align="center" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="create_time" label="申请时间" align="center" width="180">
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-tooltip class="item" effect="light" content="拒绝" placement="top">
            <i class="fa fa-times icon-style" @click="deleteList(scope.row.id)"></i>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @current-change="handleCurrentChange" layout="total,prev,pager,next" :total="total"
                   class="table-page-style"></el-pagination>
  </div>
</template>

<script>
  import { postDataToServer } from '../../assets/js/post.js'
  import { formatterTime } from '../../assets/js/common.js'
  import { getStaticMapList } from '../../assets/js/GlobeDefine.js'

  export default {
    name: 'DeliverList',
    props: ['status'],
    data () {
      return {
        resumeList: [],
        total: 0,
        page_no: 1
      }
    },
    created () {
      this.getResumeList()
    },
    methods: {
      handleCurrentChange (pageNum) {
        this.page_no = pageNum
      },
      deleteList (id) {
        let _this = this
        _this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let param = new Object()
          param.id = id
          postDataToServer('HM_RESUME_DELIVERY_DEL', param)
            .then((data) => {
              if (data.status === 0) {
                _this.$message({
                  showClose: true,
                  message: '删除成功！'
                })
                _this.$emit('delete', true)
              } else {
                _this.$message({
                  showClose: true,
                  message: '删除失败！'
                })
              }
              _this.getResumeList(_this.page_no)
            })
        }).catch(() => {
          _this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      },
      getResumeList () {
        let _this = this
        let params = new Object()
        params.page_no = _this.page_no
        params.page_size = 20
        if (_this.status !== 0) {
          params.status = _this.status
        }
        postDataToServer('HM_RESUME_DELIVERY_LISTPAGE', params).then((data) => {
          if (data.status === 0) {
            _this.resumeList = data.data_list
            _this.total = data.total_results
          }
        })
      }
    },
    watch: {
      page_no: function (val, oldVal) {
        this.getResumeList(val)
      }
    }
  }
</script>

<style scoped>
  .icon-style {
    font-size: 20px;
    color: #20a0ff;
    margin: 5px;
    cursor: pointer;
  }
</style>
